package com.hzf.wxplatform.web.controller.manager.owner;

import com.hzf.common.base.BaseController;
import com.hzf.common.util.ByteUtils;
import com.hzf.common.util.RedisUtil;
import com.hzf.ucenter.dao.model.UcenterUser;
import org.springframework.session.Session;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/ownerUser")
public class OwnerUserController extends BaseController {
    private final static String HZF_WX_CLIENT_SESSION_ID = "hzf-upms-client-session-id";

    @RequestMapping(value = "/index")
    private String index(Model model, HttpServletRequest request, HttpServletResponse response){
        HttpSession session = request.getSession();
        UcenterUser ucenterUser = new UcenterUser();
        Integer userID = (Integer) session.getAttribute(HZF_WX_CLIENT_SESSION_ID + "userid");
        System.out.println(userID);
        if(userID!=null){
            String key = "user"+userID.toString();
            byte [] b = RedisUtil.get(key.getBytes());
            if(b!=null){
                ucenterUser=(UcenterUser) ByteUtils.ByteToObject(b);
            }
        }
        model.addAttribute("user",ucenterUser);
        return  thymeleaf("/YZ/YZ_GR_KHSingle");
    }
}
